package arithmetic.functionTest.myStream;

import java.util.Iterator;

/**
 * Created on 2020-04-26
 */
public abstract class MyPipelinHelper<P_OUT> {

    /**
     * 包装每部操作
     * @param sink
     * @param <P_IN>
     * @return
     */
    abstract<P_IN> MySink<P_IN> wrapSink(MySink<P_OUT> sink);

    /**
     * 终止操作去调用, 例如 forEach, collect
     * @param sink
     * @param spliterator
     * @param <P_IN>
     * @param <S>
     * @return
     */
    abstract<P_IN, S extends MySink<P_OUT>> S wrapAndCopyInto(S sink, Iterator<P_IN> spliterator);

    /**
     *具体执行包装好的Sink, 供 wrapAndCopyInto来调用
     */
   // abstract<P_IN> void copyInto(MySink<P_IN> wrappedSink, Iterator<P_IN> spliterator);

}
